class Solution1745 {
    public static void main(String[] args) {
        System.out.println(checkPartitioning("abcbdd"));
    }
    public static boolean checkPartitioning(String s) {
        if(s == null || s.length() == 0 || s.length() == 1 ) return true ;
        char[] arr = s.toCharArray() ;
        int len = s.length() ;
        boolean[][] dp = new boolean[len][len] ;
        for(int i=len-1 ; i >= 0  ; i --){
            for(int j= i  ; j < len ; j ++){
                if(arr[i] == arr[j]){
                    if(i == j || (i+1 == j)){
                        dp[i][j] = true ;
                    }else{
                        dp[i][j] = dp[i+1][j-1] ;
                    }
                }else{
                    dp[i][j] = false ;
                }
            }
        }
        for(int i=0 ; i < len-2 ;i ++){
            for(int j=i+1 ; j < len-1 ; j ++){
                if(dp[0][i] && dp[i+1][j] && dp[j+1][len-1] == true){
                    return true ;
                }
            }
        }

        return false ;
        
    }
}